#include "xcom_handler.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <utils/logger.h>
#include <vendor_global.h>

namespace protocol {
XComHandler::XComHandler() {}

XComHandler::~XComHandler() { xComParser_.Clear(); }

std::shared_ptr<XComHandler> XComHandler::GetXComInstance()
{
	static std::shared_ptr<XComHandler> staticXComHandler = nullptr;
	static std::once_flag initFlag;

	std::call_once(initFlag,
		[&]() { staticXComHandler = std::make_shared<XComHandler>(); });
	return staticXComHandler;
}

bool XComHandler::LoadProtocol(const std::string &filePath)
{
	return xComParser_.LoadXComFile(filePath);
}

std::shared_ptr<XComNode> XComHandler::GetXComNode(const std::string &id)
{
	return xComParser_.GetXComNode(id);
}
} // namespace protocol